#include<iostream>
#include<cstring>
#include"Inode.h"
#include"Kernel.h"
#include"FileManager.h"
#include"Booters.h"
#include"Hookers.h"
#include"KonkikyoShell.h"
using namespace std;
Kernel Kernel::instance;


DevAndBuf* devLayer;

Disk* disklayer;
FileManager* thefilemanager;
User* theuser;
void adjustPtr()
{
	devLayer = &Kernel::Instance().GetDevAndBuf();
	disklayer = &Kernel::Instance().GetDisk();
	theuser = &Kernel::Instance().GetUser();
	thefilemanager = &Kernel::Instance().getFileManager();
}
void beforework()
{
	adjustPtr();
	devLayer->init();
}
void afterwork()
{
	devLayer->outit();
}
char InsideOut[6 * 1024 * 1024];
int main()
{
	beforework();
	//int qqfeiche = 0;
	disklayer->format();
	disklayer->make_FS();
	thefilemanager->Initialize();
	
	Booters::mknod("/bin");
	Booters::mknod("/etc");
	Booters::mknod("/home");
	Booters::mknod("/dev");
	Booters::cd("/bin");
	KonkikyoShell shell;
	shell.init(InsideOut);
	shell.run();
	afterwork();
	return 0;

	Booters::mknod("/j1");
	Booters::mknod("/j2");
	Booters::cd("/j1");
	Booters::mknod("h1");
	Booters::mknod("h2");
	Booters::ls();

	//Booters::copyinto("in.png", "/mypic", InsideOut);
	//Booters::copyout("out1515.png", "/mypic", InsideOut, 2227618);

	afterwork();
	return 0;
}